package parkshop.pmcourse.conf;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import parkshop.pmcourse.interceptor.AdministratorCtrlInterceptor;
import parkshop.pmcourse.interceptor.CustomerCtrlInterceptor;
import parkshop.pmcourse.interceptor.ShopOwnerCtrlInterceptor;
import parkshop.pmcourse.interceptor.UserSecurityInterceptor;

/**
 * web页面配置类，拦截器地址在此注册
 */
@Configuration

public class WebMvcConf extends WebMvcConfigurerAdapter{
	
	@Autowired
    private UserSecurityInterceptor securityInterceptor;
	@Autowired
	private CustomerCtrlInterceptor customerInterceptor;
	@Autowired
	private ShopOwnerCtrlInterceptor shopOwnerInterceptor;
	@Autowired
	private AdministratorCtrlInterceptor administratorInterceptor;
  
    @Override    
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(securityInterceptor).addPathPatterns("/**");//
        registry.addInterceptor(customerInterceptor).addPathPatterns(customerInterceptor.path);//
        registry.addInterceptor(shopOwnerInterceptor).addPathPatterns(shopOwnerInterceptor.path);//
        registry.addInterceptor(administratorInterceptor).addPathPatterns(administratorInterceptor.path);//
         }
}
